$(function () {
    var queryUrl = '../devplangc/list';
    var Id = getQueryString('Id');
    if (Id) {
        queryUrl += '?Id=' + Id;
    }
    $("#jqGrid").Grid({
        url: queryUrl,
        rownumWidth: 35,
        colModel: [
            {label: '工单号', name: 'repairCode', index: 'REPAIR_CODE', width: 150},
            {label: '单位', name: 'workshopName', width: 100},
            {label: '区域', name: 'productLineName', width: 120},
            {label: '工序号', name: 'proceNo', width: 80},
            {label: '设备名称', name: 'devName', index: 'DEV_ID', width: 130},
            {
                label: '开始日期', name: 'startTime', index: 'START_TIME', width: 90,
                formatter: function (v) {
                    return transDate(v, 'yyyy-MM-dd')
                }
            },
            {
                label: '结束日期', name: 'finalEndTime', index: 'FINAL_END_TIME', width: 90,
                formatter: function (v) {
                    return transDate(v, 'yyyy-MM-dd')
                }
            },
            {
                label: '状态', index: 'STATUS', width: 60, formatter: function (value, col, row) {
                    var v = row.status;
                    return sysEnums.MAINTENANCE_TICKET_STATUS[v];
                }
            },
            {
                label: '来源',
                index: 'TICKET_TYPE',
                width: 70,
                formatter: function (value, col, row) {
                    return sysEnums.TICKET_TYPE[row.ticketType];
                }
            },
            {label: '实施人', name: 'executorName', index: 'EXECUTOR', width: 120},
            {
                label: '详情', width: 60, sortable: false,
                formatter: function (value, col, row) {
                    return "<button class='btn btn-outline btn-info' id='recordsText' onclick='vm.gdDetail(\"" + row.id + "\",\"" + row.ticketType + "\")'>&nbsp;<i class='fa fa-qrcode'></i></button>";
                }
            },
            {
                label: '换件记录', width: 60, sortable: false,
                formatter: function (value, col, row) {
                    return "<button title='' class='btn btn-outline btn-info' onclick='vm.addReplacePartRecord(\"" + row.id + "\")'><i class='fa fa-file-text-o'></i></button>";
                }
            },
            {
                label: '异常查看', sortable: false, width: 60,
                formatter: function (value, col, row) {
                    return "<button class='btn btn-outline btn-info' id='showText' onclick='vm.ycDetail(\"" + row.id + "\")'>&nbsp;<i class='fa fa-file-text-o'></i></button>";
                }
            },
            {name: 'ticketType', hidden: true},
            {name: 'devId', hidden: true},
            {name: 'isUrged', hidden: true},
            {name: 'endTime', hidden: true},
            {name: 'status', hidden: true},
            {name: 'id', key: true, hidden: true},
        ]
    });
    vm.getTreeList();
    vm.getStore();
});
var setting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "deptId",
            pIdKey: "parentId",
            rootPId: -1
        },
        key: {
            url: "nourl"
        }
    },
    callback: {
        beforeCheck: true
    }

};
//部门树
var deptSetting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "deptId",
            pIdKey: "parentId",
            rootPId: -1
        },
        key: {
            url: "nourl",
            name: "complexName"
        }
    },
    callback: {
        beforeCheck: true,
        beforeClick: outTreeCheck
    }
};

function outTreeCheck(e, treeObj, treeNode) {
    vm.q.deptCode = treeObj.deptId;
    vm.query();
}

var vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        showForm: false,
        temporaryShow: false,
        devPlanGc: {
            delFlag: '',
            createUser: '',
            createDate: '',
            deptCode: '',
            devOption: '',
            devGc: '',
            devPlan: '',
            id: '',
            devProceNo: '',
            problemDescribe: '',
            approvalStatus: ''
        },
        devProductCode: '',
        devPlanGc: {
            delayTime: ''
        },
        option: {},
        devReportUrge: {},
        repairUserList: {},
        devPlanGcDate: {},
        ruleValidate: {
            devCode: [
                {required: true, message: '设备必选', trigger: 'change'}
            ],
            startDate: [
                {required: true, message: '开始日期必选', trigger: 'change'}
            ],
            endDate: [
                {required: true, message: '结束日期必选', trigger: 'change'}
            ],
            desc: [
                {required: true, message: '问题描述必填', trigger: 'blur'}
            ],
            step: [
                {required: true, message: '措施必填', trigger: 'blur'}
            ]
        },
        q: {
            name: '',
            deptCode: '',
            repairCode: '',
            ticketType: '',
            status: '',
            statusArray: [],
            executeTime: '',
            executeEndTime: ''
        },
        freRateArray: enumsToListWithNull('FRERATE'),
        typeList: enumsToList('MAINTENPLAN_TYPE'),//类型
        ticketTypeList: enumsToListWithoutChange('TICKET_TYPE'),
        ticketStatusList: enumsToList('MAINTENANCE_TICKET_STATUS'),
        // 新增临时计划VO
        devMaintenPlan: {
            devName: '', // 设备名称
            lineCode: '', // 产线编码
            lineName: '', // 产线名称
            devProceNo: '', // 工序编码
            devProceName: '', // 工序名称
            devCode: '', // 设备编码
            startDate: '', // 工单开始时间
            endDate: '', // 工单结束时间
            desc: '',  // 问题描述
            step: '' // 措施
        },
        // 维修工单派工参数
        ticketDispatchParam: {
            ticketIdList: [], // 维护工单ID列表
            executor: [] // 维修用户
        },
        // 工单延期申请参数
        ticketChangeParam: {
            ticketId: '',
            changeTime: '',
            item: '',
            reason: '',
        },
        // 延期审核参数
        delayCheckParam: {
            ticketId: '', // 维护工单ID
            approvalStatus: 1
        },
        mainPersonnel: [],//维护人员列表
    },
    watch: {
        'q.statusArray': function (val, oldval) {
            vm.q.status = vm.q.statusArray.join(',');
        }
    },
    methods: {
        //时间界面修改
        timeChange(e) {
            vm.q.executeTime = e[0];
            vm.q.executeEndTime = e[1]
        },
        //点击选择框，进行删除
        pointPopup(Item, index) {
            this.mainPersonnel.splice(index, 1);
            for (let i = 0; i < this.ticketDispatchParam.executor.length; i++) {
                if (Item.userId == this.ticketDispatchParam.executor[i]) {
                    this.ticketDispatchParam.executor.splice(i, 1)
                }
            }
        },
        /**
         * 1.检查这个id在数组中有没有，有删除，没有加入
         *
         * @param id
         */
        pointPersonnel(Item) {
            if (this.ticketDispatchParam.executor.length > 6) {
                alert('维护人员最多7个');
                return
            }
            if (Item.userId) {
                if (this.ticketDispatchParam.executor.length > 0) {
                    //添加
                    if (this.ticketDispatchParam.executor.indexOf(Item.userId) == -1) {
                        this.ticketDispatchParam.executor.push(Item.userId)
                    } else {
                        //删除
                        for (let i = 0; i < this.ticketDispatchParam.executor.length; i++) {
                            if (Item.userId == this.ticketDispatchParam.executor[i]) {
                                this.ticketDispatchParam.executor = this.ticketDispatchParam.executor.filter(item => !item.toString().includes(Item.userId))
                            }
                        }
                    }
                } else {
                    this.ticketDispatchParam.executor.push(Item.userId)
                }
                //进行第二步 在push 人名数组
                this.mainPersonnel = []
                for (let i = 0; i < this.ticketDispatchParam.executor.length; i++) {
                    for (let j = 0; j < this.repairUserList.length; j++) {
                        if (this.ticketDispatchParam.executor[i] == this.repairUserList[j].userId) {
                            this.mainPersonnel.push({
                                name: this.repairUserList[j].userName,
                                userId: this.repairUserList[j].userId
                            })
                        }
                    }
                }
            }
        },
        // 关联备件换件记录
        addReplacePartRecord: function (ticketId) {
            openWindow({
                type: 2,
                area: ['100%', '100%'],
                title: '<i class="fa fa-bars"></i> 设备维护换件记录',
                content: '../spare/sparepartconsumrecord.html?businessId=' + ticketId + '&type=MAINTENANCE&materialType=3'
            })
        },
        query: function () {
            vm.reload();
        },
        add: function () {
            vm.showList = false;
            vm.temporaryShow = false;
            vm.showForm = true;
            vm.title = "新增";
            vm.devPlanGc = {
                delFlag: '',
                createUser: '',
                createDate: '',
                deptCode: '',
                devOption: '',
                devGc: '',
                devPlan: '',
                id: '',
                devProceNo: '',
                problemDescribe: '',
            };
        },
        getTreeList: function () {
            Ajax.request({
                url: '../sys/user/treeDeptBySCX',
                async: false,
                successCallback: function (r) {
                    vm.treeList = r.list;
                }
            });
        },
        //加载列表页树
        getStore: function () {
            deptZtree = $.fn.zTree.init($("#storeTree"), deptSetting, vm.treeList);
            // 默认展开工厂一级
            deptZtree.expandNode(deptZtree.getNodeByParam("deptId", '01', null));
        },
        getTree: function () {
            //加载分类树
            ztree = $.fn.zTree.init($("#categoryTree"), setting, vm.treeList);
            ztree.expandAll(true);
            var node = ztree.getNodeByParam("deptId", vm.deviceInfo.devProductCode);
            if (node) {
                ztree.selectNode(node);
                vm.deviceInfo.devProductName = node.name;
                ztree.expandNode(node);
            } else {
                node = ztree.getNodeByParam("deptId", "0");
                ztree.selectNode(node);
            }
        },

        update: function (event) {
            var id = getSelectedRow("#jqGrid");
            if (id == null) {
                return;
            }
            vm.showList = false;
            vm.temporaryShow = false;
            vm.showForm = true;
            vm.title = "修改";

            vm.getInfo(id);
        },
        saveOrUpdate: function (event) {
            var url = vm.devPlanGc.id == (null || '') ? "../devplangc/save" : "../devplangc/update";
            Ajax.request({
                url: url,
                params: JSON.stringify(vm.devPlanGc),
                type: "POST",
                contentType: "application/json",
                successCallback: function (r) {
                    alert('操作成功', function (index) {
                        layer.closeAll();
                        vm.reload();
                    });
                }
            });
        },
        del: function (event) {
            // 只可以删除检修&未执行的工单
            var selectedRowDatas = getSelectedRowDatas("#jqGrid");
            debugger
            for (let i = 0; i < selectedRowDatas.length; i++) {
                if (selectedRowDatas[i].ticketType != 'TEM' || selectedRowDatas[i].status >= 4) {
                    iview.Message.error("只可以删除自己车间未执行的检修工单！");
                    return;
                }
            }
            var ids = getSelectedRows("#jqGrid");
            if (ids == null) {
                return;
            }
            confirm('确定要删除选中的记录？', function () {
                Ajax.request({
                    url: "../devplangc/delete",
                    params: JSON.stringify(ids),
                    type: "POST",
                    contentType: "application/json",
                    successCallback: function () {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    }
                });
            });
        },
        getInfo: function (id) {
            Ajax.request({
                url: "../devplangc/info/" + id,
                async: true,
                successCallback: function (r) {
                    vm.devPlanGc = r.devPlanGc;
                }
            });
        },
        reload: function (isCurrent) {
            if (this.q.executeTime) {
                this.q.executeTime = gmt2DateStr(this.q.executeTime);
            }
            if (this.q.executeEndTime) {
                this.q.executeEndTime = gmt2DateStr(this.q.executeEndTime);
            }
            vm.temporaryShow = false;
            vm.showForm = false;
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            // 设置当前页码
            currentPageNo = isCurrent ? page : 1;
            $("#jqGrid").jqGrid('setGridParam', {
                search: true,
                postData: vm.q,
                page: page
            }).trigger("reloadGrid", [{page: currentPageNo}]);
            vm.handleReset('formValidate');
        },
        reloadSearch: function () {
            vm.q = {
                name: '',
                deptCode: '',
                repairCode: '',
                ticketType: '',
                status: '',
                statusArray: [],
                executeTime: '',
                executeEndTime: ''
            };
            // 取消选中
            deptZtree.cancelSelectedNode();
            vm.reload();
        },
        // 导出工单周执行状况统计
        exportData: function () {
            if (!this.q.executeTime) {
                iview.Message.error("请选择工单执行周次！");
                return;
            }
            // 查询条件数组
            let queryConditionArray = [];
            if (this.q.name) {
                queryConditionArray.push('name=' + this.q.name);
            }
            if (this.q.deptCode) {
                queryConditionArray.push('deptCode=' + this.q.deptCode);
            }
            if (this.q.repairCode) {
                queryConditionArray.push('repairCode=' + this.q.repairCode);
            }
            if (this.q.ticketType) {
                queryConditionArray.push('ticketType=' + this.q.ticketType);
            }
            if (this.q.status) {
                queryConditionArray.push('devLineId=' + this.q.status);
            }
            if (this.q.executeEndTime) {
                queryConditionArray.push('executeEndTime=' + gmt2DateStr(this.q.executeEndTime));
            }
            if (this.q.executeTime) {
                queryConditionArray.push('executeTime=' + gmt2DateStr(this.q.executeTime));
            }
            let exportUrl = '../devplangc/export'
            if (queryConditionArray.length > 0) {
                exportUrl += '?' + queryConditionArray.join('&')
            }
            window.open(exportUrl, '_blank');
        },
        handleSubmit: function (name) {
            handleSubmitValidate(this, name, function () {
                vm.saveOrUpdate()
            });
        },
        //临时计划
        temporary: function () {
            vm.showForm = false;
            vm.showList = false;
            vm.temporaryShow = true;
            vm.title = "新增检修计划";
            vm.devMaintenPlan = {
                devId: '', // 设备ID
                devCode: '', // 设备编码
                devName: '', // 设备名称
                lineCode: '', // 产线编码
                lineName: '', // 产线名称
                devProceNo: '', // 工序编码
                devProceName: '', // 工序名称
                startDate: '', // 工单开始时间
                endDate: '', // 工单结束时间
                desc: '',
                step: '',
                planType: 'TEM'
            }
        },
        handleSubmit2: function (name) {
            handleSubmitValidate(this, name, function () {
                vm.saves()
            });
        },
        handleReset: function (name) {
            handleResetForm(this, name);
            vm.handleResetRem('formValidateResource');
        },
        saves: function () {
            // 处理下日期格式
            if (vm.devMaintenPlan.startDate) {
                vm.devMaintenPlan.startDate = gmt2DateStr(vm.devMaintenPlan.startDate);
            }
            if (vm.devMaintenPlan.endDate) {
                vm.devMaintenPlan.endDate = gmt2DateStr(vm.devMaintenPlan.endDate);
            }
            Ajax.request({
                url: '../devplangc/save',
                params: JSON.stringify(vm.devMaintenPlan),
                type: "POST",
                contentType: "application/json",
                successCallback: function (r) {
                    alert('操作成功', function (index) {
                        vm.reload();
                    });
                }
            });
        },
        getDeviceInfo: function () {
            openWindow({
                type: 2,
                title: '<i class="fa fa-file-text-o"></i> 选择设备',
                content: '../sys/deviceInfoSelect.html',
                btn: ['确定', '取消'],
                btn1: function (index) {
                    var iframeWin = window["layui-layer-iframe" + index];
                    var res = iframeWin.getDeviceInfo();
                    if (!res) {
                        iview.Message.error("请选择一条记录");
                    } else {
                        vm.devMaintenPlan.lineCode = res.devProductCode;
                        vm.devMaintenPlan.lineName = res.devProductName;
                        vm.devMaintenPlan.devProceNo = res.devProceNo;
                        vm.devMaintenPlan.devProceName = res.devProceName;
                        vm.devMaintenPlan.devId = res.id;
                        vm.devMaintenPlan.devCode = res.devCode;
                        vm.devMaintenPlan.devName = res.devName;
                        vm.devMaintenPlan.deptId = res.devFarm;
                        layer.close(index);
                    }
                }
            })
        },
        handleReset: function (name) {
            handleResetForm(this, name);
        },
        /**
         * 展示工单选项
         * @param id
         */
        gdDetail: function (id, ticketType) {
            let url = (ticketType === 'PLAN') ? '../device/devMainBaseCheck.html?id=' + id : '../device/devMaintenanceTicketItemCheck.html?id=' + id;
            //根据维护工单id 查询所有维护项
            openWindow({
                type: 2,
                area: ['100%', '100%'],
                title: '<i class="fa fa-pencil"></i> 维护工单详情',
                content: url,
                cancel: function () {
                    // 右上角关闭事件的逻辑
                    vm.reload(true);
                }
            })
        },
        /**
         * 维护选项
         * @param id
         */
        whDetail: function (id) {
            //根据维护工单id 查询所有维护项
            openWindow({
                type: 2,
                title: '<i class="fa fa-pencil"></i> 维护项',
                content: '../device/devMainBaseCheck.html?id=' + id
            })
            // openWindow({
            //     type: 2,
            //     title: '<i class="fa fa-file-text-o"></i> 查看详情',
            //     content: '../device/devplandetailsView.html?plan_id='+ id
            // })
        },
        ycDetail: function (id) {
            //异常展示
            openWindow({
                type: 2,
                area: ['100%', '100%'],
                title: '<i class="fa fa-pencil"></i> 维护项',
                content: '../device/exceperrorView.html?originRecordId=' + id
            })
        },
        dispatchTicket: function () {
            // 工单ID列表
            var ticketIdList = [];
            vm.mainPersonnel = [];
            var ticketList = getSelectedRowDatas("#jqGrid");
            if (ticketList == null) {
                return;
            }
            for (let i = 0; i < ticketList.length; i++) {
                var ticket = ticketList[i];
                if (ticket.status != 1 && ticket.status != 2 && ticket.status != 3 && ticket.status != 10) {
                    alert(ticket.repairCode + "不是可分派工单，只有 [待分派、待执行、已超期] 状态工单才可以派工！");
                    return;
                }
                ticketIdList.push(ticket.id);
            }
            vm.ticketDispatchParam = {
                ticketIdList: ticketIdList,
                executor: []
            };
            // 获取当前车间维修工列表
            vm.getAssign();
            //任务指派后工单状态变为维修中
            openWindow({
                title: "选择人员",
                area: ['800px', '450px'],
                content: jQuery("#select"),
                btn: ['确定', '取消'],
                btn1: function (index) {
                    layer.close(index);
                    Ajax.request({
                        url: '../devplangc/dispatchTicket',
                        params: JSON.stringify(vm.ticketDispatchParam),
                        type: 'POST',
                        contentType: "application/json",
                        successCallback: function (r) {
                            alert('派工成功', function (index) {
                                vm.reload();
                                layer.close(index);
                            });
                        }
                    })
                }
            });
        },
        urge: function () {
            var id = getSelectedRow("#jqGrid");
            if (id == null) {
                return;
            }
            vm.devMaintenPlan = getSelectedRowData("#jqGrid");
            if (vm.devMaintenPlan.isUrged == '1') {
                layer.alert('催办处理中，请耐心等待！', {icon: 5});
                return;
            }
            vm.devReportUrge.repairNo = id;
            //插入记录
            confirm('确定要催办选中的记录？', function () {
                Ajax.request({
                    url: "../devplangc/urgeSave",
                    params: JSON.stringify(vm.devReportUrge),
                    type: "POST",
                    contentType: "application/json",
                    successCallback: function (r) {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    }
                });
            });

        },
        getAssign: function () {
            //获取当前登录部门的维修组人员信息
            Ajax.request({
                url: '../devmaintenwork/repairUser',
                async: false,
                successCallback: function (r) {
                    vm.repairUserList = r.repairUserList;
                }
            })
        },
        addError: function () {
            //异常添加
            let result = getSelectedRowData("#jqGrid");
            var id = result.id;
            if (id == null) {
                return false;
            }
            openWindow({
                type: 2,
                title: '<i class="fa fa-bars"></i> 添加异常记录',
                area: ['600px', '400px'],
                content: '../device/addExcepRecord.html?id=' + id + '&devId=' + result.devId + '&source=DEV_MAINTENANCE_TICKET',
                btn: ['确定', '取消'],
                btn1: function (index) {
                    var iframeWin = window["layui-layer-iframe" + index];
                    var res = iframeWin.getExcept();
                    if (res.endDate) {
                        res.endDate = gmt2DateStr(res.endDate)
                    }
                    if (res.startDate) {
                        res.startDate = gmt2DateStr(res.startDate)
                    }
                    if (res != null) {
                        Ajax.request({
                            url: "../deviceinfo/uploadException",
                            params: JSON.stringify(res),
                            type: "POST",
                            contentType: "application/json",
                            successCallback: function (r) {
                                alert('操作成功', function (index) {
                                    vm.reload();
                                });
                            }
                        });
                    }
                    layer.close(index);
                }
            });
        },
        // 计划变更申请
        applyChange: function () {
            var id = getSelectedRow("#jqGrid");
            if (id == null) {
                return;
            }
            var currentTicket = getSelectedRowData("#jqGrid");
            if (currentTicket.status == '5') {
                iview.Message.error('延期申请中，请耐心等待！');
                return;
            }
            if (currentTicket.status == '7' || currentTicket.status == '8' || currentTicket.status == '9') {
                iview.Message.error('工单已完成或已关闭，不允许延期！');
                return;
            }
            // 工单变更参数
            vm.ticketChangeParam = {
                ticketId: currentTicket.id,
                changeTime: '',
                item: '',
                reason: ''
            };
            openWindow({
                title: "延期申请",
                area: ['600px', '400px'],
                content: jQuery("#apply"),
                btn: ['确定', '取消'],
                btn1: function (index) {
                    if (vm.ticketChangeParam.changeTime) {
                        vm.ticketChangeParam.changeTime = gmt2DateStr(vm.ticketChangeParam.changeTime);
                    }
                    Ajax.request({
                        url: '../devplangc/applyDelay',
                        params: JSON.stringify(vm.ticketChangeParam),
                        type: "POST",
                        contentType: "application/json",
                        successCallback: function (r) {
                            alert('操作成功', function (index) {
                                layer.closeAll();
                                vm.reload();
                            });
                        }
                    });
                }
            });
        },
        delayApply: function () {
            var id = getSelectedRow("#jqGrid");
            if (id == null) {
                return;
            }
            var date = getSelectedRowData("#jqGrid");
            if (date.status != '5') {
                alert("当前记录未申请延期");
            } else {
                vm.delayCheckParam = {
                    ticketId: id, // 维护工单ID
                    approvalStatus: 5
                }
                openWindow({
                    title: '延期审核',
                    content: jQuery("#applySwitch"),
                    area: ['450px', '250px'],
                    btn: ['确定', '取消'],
                    btn1: function (index) {
                        vm.devPlanGc.id = id;
                        Ajax.request({
                            url: '../devplangc/delayApply',
                            params: JSON.stringify(vm.delayCheckParam),
                            type: "POST",
                            contentType: "application/json",
                            successCallback: function (r) {
                                alert('操作成功', function (index) {
                                    vm.reload();
                                    layer.closeAll();
                                });
                            }
                        })
                    }
                });
            }
        },
        error: function () {
            var id = getSelectedRow("#jqGrid");
            if (id == null) {
                return;
            }
            var date = getSelectedRowData("#jqGrid");

        }
        ,
        test: function () {
            Ajax.request({
                url: '../devplangc/test',
                params: JSON.stringify(vm.devPlanGc),
                type: "POST",
                contentType: "application/json",
                successCallback: function (r) {
                    alert('操作成功', function (index) {
                        vm.reload();
                        layer.closeAll();
                    });
                }
            })
        }
    },
    computed: {
        line: function () {
            if (this.devMaintenPlan) {
                if (this.devMaintenPlan.lineCode && this.devMaintenPlan.lineName) {
                    return this.devMaintenPlan.lineCode + ' ' + this.devMaintenPlan.lineName
                }
            }
            return '';
        },
        proce: function () {
            if (this.devMaintenPlan) {
                if (this.devMaintenPlan.devProceNo && this.devMaintenPlan.devProceName) {
                    return this.devMaintenPlan.devProceNo + ' ' + this.devMaintenPlan.devProceName
                }
            }
            return '';
        }
    }
});

function getInfoList(id) {
    var a = false;
    Ajax.request({
        url: "../devplangcrecord/infoList",
        params: JSON.stringify({'id': id}),
        async: false,
        type: "POST",
        contentType: "application/json",
        successCallback: function (r) {
            var list = r.list;
            for (var i in list) {
                var date = list[i];
                if (date.freRate > 1) {
                    a = true
                }
            }
        }
    });

    return a;
}
